function addUpBtn(zTree, aObj, treeNode) {
  var sel = 'diyBtn_' + treeNode.id + '_up'
  var jqEle = $('#' + sel)
  if (jqEle.length > 0) return
  var editStr = `<button class="treeCtrlBtn" id="${sel}">up</button>`
  aObj.append(editStr)
  var btn = jqEle
  if (btn)
    btn.bind('click', function (e) {
      e.preventDefault()
      e.stopPropagation()
      let parentNode = treeNode.getParentNode()
      let tmpNode = treeNode.getPreNode()
      if (tmpNode && parentNode) {
        zTree.moveNode(tmpNode, treeNode, 'prev')
        zTree.refresh()
        // setTimeout(() => {
        //   MoveTest.updateType()
        // }, 300)
      }
    })
}

function addDownBtn(zTree, aObj, treeNode) {
  // console.log(treeNode)
  var sel = 'diyBtn_' + treeNode.id + '_down'
  var jqEle = $('#' + sel)
  if (jqEle.length > 0) return
  var editStr = `<button class="treeCtrlBtn" id="${sel}">down</button>`
  aObj.append(editStr)
  var btn = jqEle
  if (btn)
    btn.bind('click', function (e) {
      e.preventDefault()
      e.stopPropagation()
      let parentNode = treeNode.getParentNode()
      let tmpNode = treeNode.getNextNode()
      if (tmpNode && parentNode) {
        zTree.moveNode(tmpNode, treeNode, 'next')
        zTree.refresh()
        // setTimeout(() => {
        //   MoveTest.updateType()
        // }, 300)
      }
    })
}

export function addDiyDom(treeId, treeNode) {
  var zTree = MoveTest.getZtree()
  var aObj = $('#' + treeNode.tId + '_a')

  addUpBtn(zTree, aObj, treeNode)
  addDownBtn(zTree, aObj, treeNode)
}
